*** Generating figure 3: Baseline results for the full sample ***

** Preamble **

clear all
set more off

local path_input  "C:/Users/$user/Dropbox/$project/master/input/folha"
local path_output "C:/Users/$user/Dropbox/$project/master/output/figures"

* Note: local directory is the output folder 
cd "`path_output'"


			** Loading .xls data inputed from Folha de Sao Paulo's cover ** 

import excel `path_input'/data_trends.xlsx, sheet("Foglio1") firstrow 

rename Collor collor 
rename Lula lula

*** Generating graph with trends ***

label variable month  "month"
label variable lula   "Lula"
label variable collor "Collor"

gen order=_n

gen     order_scale=1  if _n==1
replace order_scale=9  if _n==2
replace order_scale=12 if _n==3
replace order_scale=17 if _n==4
replace order_scale=22 if _n==5
replace order_scale=25 if _n==6

			
					** Graph: reverse of electoral trends **


twoway ///
(connect collor order_scale, ///
lw(thick) lp(dash) text(24 55 "edited highlights", place(c)) /// 
mlabel(collor) mlabsize(3) msize(medsmall) mlabcolor(black) msymbol(oh) mlabp(12) ) ///
(connect lula order_scale, ///
lw(thick) ///
mlabel(lula) mlabsize(3) msize(medsmall) mlabcolor(black) msymbol(oh) mlabp(6)), ///
graphregion(color(white)) bgcolor(white) ///
xlab(1 "Nov 22" 9 "Nov 30" 12 "Dec 04" 17 "Dec 08" 21.5 "Dec 12/13" 25 "Dec 16", tlength(0)) ///
ylab(none, tlength(0)) ///
xtitle("") ///
ytitle("Voting intentions in p.p.") ///
xscale(lcolor(none) range(0 28)) ///
yscale(lcolor(none) range(38 50)) ///
xline(23, lcolor(black) lw(medium) lp(dot)) ///
xline(24, lcolor(black) lw(medium) lp(dot)) 

* note(Adapted by the authors from Pacheco and Alberico (2012)) 

graph export trends_graph.png, replace
